3 function wfSpecialIpblocklist()
5 global $wgUser, $wgOut, $wgRequest;
7 $ip = $wgRequest->getVal( 'wpUnblockAddress', $wgRequest->getVal( 'ip' ) );
8 $reason = $wgRequest->getText( 'wpUnblockReason' );
9 $action = $wgRequest->getText( 'action' );
11 $ipu = new IPUnblockForm( $ip, $reason );
13 if ( "success" == $action ) {
14 $msg = wfMsg( "ipusuccess", $ip );
15 $ipu->showList( $msg );
16 } else if ( "submit" == $action && $wgRequest->wasPosted() ) {
17 if ( ! $wgUser->isSysop() ) {
18 $wgOut->sysopRequired();
22 } else if ( "unblock" == $action ) {
32 function IPUnblockForm( $ip, $reason ) {
34 $this->reason
= $reason;
37 function showForm( $err )
39 global $wgOut, $wgUser, $wgLang;
41 $wgOut->setPagetitle( wfMsg( "unblockip" ) );
42 $wgOut->addWikiText( wfMsg( "unblockiptext" ) );
44 $ipa = wfMsg( "ipaddress" );
45 $ipr = wfMsg( "ipbreason" );
46 $ipus = htmlspecialchars( wfMsg( "ipusubmit" ) );
47 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
48 $action = $titleObj->escapeLocalURL( "action=submit" );
51 $wgOut->setSubtitle( wfMsg( "formerror" ) );
52 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
56 <form id=\"unblockip\" method=\"post\" action=\"{$action}\">
59 <td align='right'>{$ipa}:</td>
61 <input tabindex='1' type='text' size='20' name=\"wpUnblockAddress\" value=\"" . htmlspecialchars( $this->ip
) . "\" />
65 <td align='right'>{$ipr}:</td>
67 <input tabindex='1' type='text' size='40' name=\"wpUnblockReason\" value=\"" . htmlspecialchars( $this->reason
) . "\" />
73 <input tabindex='2' type='submit' name=\"wpBlock\" value=\"{$ipus}\" />
83 global $wgOut, $wgUser, $wgLang;
86 $this->ip
= trim( $this->ip
);
88 if ( $this->ip
{0} == "#" ) {
89 $block->mId
= substr( $this->ip
, 1 );
91 $block->mAddress
= $this->ip
;
94 # Delete block (if it exists)
95 # We should probably check for errors rather than just declaring success
99 $log = new LogPage( 'block' );
100 $log->addEntry( 'unblock', Title
::makeTitle( NS_USER
, $this->ip
), $this->reason
);
103 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
104 $success = $titleObj->getFullURL( "action=success&ip=" . urlencode( $this->ip
) );
105 $wgOut->redirect( $success );
108 function showList( $msg )
112 $wgOut->setPagetitle( wfMsg( "ipblocklist" ) );
114 $wgOut->setSubtitle( $msg );
116 $wgOut->addHTML( "<ul>" );
117 Block
::enumBlocks( "wfAddRow", 0 );
118 $wgOut->addHTML( "</ul>\n" );
122 # Callback function to output a block
123 function wfAddRow( $block, $tag ) {
124 global $wgOut, $wgUser, $wgLang;
126 $sk = $wgUser->getSkin();
128 # Hide addresses blocked by User::spreadBlocks, for privacy
129 $addr = $block->mAuto ?
"#{$block->mId}" : $block->mAddress
;
131 $name = User
::whoIs( $block->mBy
);
132 $ulink = $sk->makeKnownLink( $wgLang->getNsText( Namespace::getUser() ). ":{$name}", $name );
133 $formattedTime = $wgLang->timeanddate( $block->mTimestamp
, true );
135 if ( $block->mExpiry
=== "" ) {
136 $formattedExpiry = "indefinite";
138 $formattedExpiry = $wgLang->timeanddate( $block->mExpiry
, true );
141 $line = wfMsg( "blocklistline", $formattedTime, $ulink, $addr, $formattedExpiry );
143 $wgOut->addHTML( "<li>{$line}" );
145 if ( !$block->mAuto
) {
146 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Contributions" );
147 $clink = "<a href=\"" . $titleObj->escapeLocalURL( "target={$block->mAddress}" ) . "\">" .
148 wfMsg( "contribslink" ) . "</a>";
149 $wgOut->addHTML( " ({$clink})" );
152 if ( $wgUser->isSysop() ) {
153 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Ipblocklist" );
154 $ublink = "<a href=\"" .
155 $titleObj->escapeLocalURL( "action=unblock&ip=" . urlencode( $addr ) ) . "\">" .
156 wfMsg( "unblocklink" ) . "</a>";
157 $wgOut->addHTML( " ({$ublink})" );
159 if ( "" != $block->mReason
) {
160 $wgOut->addHTML( " <em>(" . htmlspecialchars( $block->mReason
) .
163 $wgOut->addHTML( "</li>\n" );